package com.monkeysonnet.b2dFluent;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef;

public class PrismaticJointFactory extends JointFactory<PrismaticJointFactory>
{
	private static final PrismaticJointDef _initialDef  = new PrismaticJointDef();
	
	private PrismaticJointDef _def;
	
	public PrismaticJointFactory()
	{
		this(false);
	}
	
	PrismaticJointFactory(boolean managed)
	{
		super(managed);
		_def = new PrismaticJointDef();
		setDef(_def);
	}
	
	public PrismaticJointFactory enableLimit(boolean e)
	{
		_def.enableLimit = e;
		return this;
	}
	
	public PrismaticJointFactory enableMotor(boolean e)
	{
		_def.enableMotor = e;
		return this;
	}
	
	public PrismaticJointFactory localAxisA(Vector2 t)
	{
		_def.localAxisA.set(t);
		return this;
	}
	
	public PrismaticJointFactory localAxisA(float x, float y)
	{
		_def.localAxisA.set(x, y);
		return this;
	}
	
	public PrismaticJointFactory lowerTranslation(float t)
	{
		_def.lowerTranslation = t;
		return this;
	}
	
	public PrismaticJointFactory maxMotorForce(float f)
	{
		_def.maxMotorForce = f;
		return this;
	}
	
	public PrismaticJointFactory motorSpeed(float s)
	{
		_def.motorSpeed = s;
		return this;
	}
	
	public PrismaticJointFactory referenceAngle(float a)
	{
		_def.referenceAngle = a;
		return this;
	}
	
	public PrismaticJointFactory upperTranslation(float t)
	{
		_def.upperTranslation = t;
		return this;
	}
	
	void clear()
	{
		super.clear(_initialDef);
		_def.enableLimit = _initialDef.enableLimit;
		_def.enableMotor = _initialDef.enableMotor;
		_def.localAnchorA.set(_initialDef.localAnchorA);
		_def.localAnchorB.set(_initialDef.localAnchorB);
		_def.localAxisA.set(_initialDef.localAxisA);
		_def.lowerTranslation = _initialDef.lowerTranslation;
		_def.maxMotorForce = _initialDef.maxMotorForce;
		_def.motorSpeed = _initialDef.motorSpeed;
		_def.referenceAngle = _initialDef.referenceAngle;
		_def.upperTranslation = _initialDef.upperTranslation;
		
	}

	@Override
	public void free()
	{
		B2d.free(this);
	}
}
